﻿package com.chaosZ.util;

public class EncrptyUtil {
	/**	
	 * 加密
	 * @param password 被加密字符串
	 * @return ls_return 加密后字符串
	 */
	public static String encrypt(String password){
	     String verify = "";
		 String ls_return = "";
		 int li_len,li_count;
		 char lc_tmp;
		if(password == null || password.isEmpty()){
			return "";
		}else{
			password += verify;
			li_len = password.length();
			for(li_count = 1;li_count <= li_len; li_count++){
				lc_tmp = (char)(password.codePointAt(li_count - 1) + (((23 * li_count) % li_len) * 3) % 7);   
				ls_return += lc_tmp;
			}
		}
		return ls_return;
	}
            
    /**	
     *  解密  
     * @param password 被解密字符串
     * @return ls_return 解密后字符串
     */
	public static String decrypt(String password){
		 String verify = "";
		 String ls_return = "";
		 int li_len,li_count;
		 char lc_tmp;
		 if(password == null || password.isEmpty()){
			 return "";
		 }else{
			password += verify;
			li_len = password.length();
			for(li_count = 1;li_count <= li_len; li_count++){
				lc_tmp = (char)(password.codePointAt(li_count - 1) - (((23 * li_count) % li_len) * 3) % 7);   
				ls_return += lc_tmp;
			}
		}
		return ls_return;
	}
}
